package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;

public class Test1 {
    public static void main(String[] args) {
        Collection<String> c = new ArrayList<>();
        c.add("java1");// 添加元素
        c.add("java2");
        c.add("java1");
        c.add("java2");
        System.out.println(c);

//        c.clear();// 清空元素
//        System.out.println(c);

        System.out.println(c.isEmpty());// 判断集合内容是否为空

        System.out.println(c.size());// 判断集合大小

        System.out.println(c.contains("java1"));
        System.out.println(c.contains("java3"));

        System.out.println(c.remove("java1"));// 删除某一个元素，默认为索引靠前的
        System.out.println(c);

        Object[] arr = c.toArray();// 集合转换成数组
        System.out.println(Arrays.toString(arr));

        Collection<String> c1 = new ArrayList<>();
        c1.addAll(c);// 将集合c的元素全部赋予给集合c1
        System.out.println(c1);
    }
}